from fastapi import APIRouter, Depends, Request
from app.api.h5.schema.order.order import OrderAppCancleInSchema, OrderAppListInSchema, OrderDetailInSchema,  OrderInSchema, OrderListInSchema
from app.api.h5.service.order.order import OrderService
from app.utils.res import unified_resp


order = APIRouter(prefix="/order", tags=["订单"])


@order.post("/add")
@unified_resp
async def add(order_in: OrderInSchema, request: Request, order_service: OrderService = Depends(OrderService.instance)):
    client_id = request.state.client_id
    print("client_id", client_id)
    return await order_service.add(client_id,order_in)


@order.post("/list")
@unified_resp
async def list(list_in: OrderListInSchema, request: Request, order_service: OrderService = Depends(OrderService.instance)):
    client_id = request.state.client_id
    print("client_id", client_id)
    return await order_service.list(client_id, list_in)


@order.post("/detail")
@unified_resp
async def detail(detail_in: OrderDetailInSchema, request: Request, order_service: OrderService = Depends(OrderService.instance)):
    client_id = request.state.client_id
    print("client_id", client_id)
    return await order_service.detail(detail_in)


@order.post("/app_list")
@unified_resp
async def app_list(app_list_in: OrderAppListInSchema, order_service: OrderService = Depends(OrderService.instance)):
    return await order_service.app_list(app_list_in)


@order.post("/app_cancel")
@unified_resp
async def app_cancel(cancel_in: OrderAppCancleInSchema, order_service: OrderService = Depends(OrderService.instance)):
    return await order_service.app_cancel(cancel_in)


@order.post("/app_statistics")
@unified_resp
async def app_statistics(order_service: OrderService = Depends(OrderService.instance)):
    return await order_service.app_statistics()
